
/**
 * @file bussiness.c
 * @brief 
 * @author  ()
 * @version 1.0
 * @date 2024-09-13
 * @defgroup task
 * 
 * @copyright Copyright (C) 2019 Queclink Wireless Solutions (ShenZhen) Co., Ltd. All Rights Reserved.
 * 
 * @par 修改日志:
 * <table>
 * <tr><th>Date       <th>Version <th>Author  <th>Description
 * <tr><td>2024-09-13 <td>1.0     <td>     <td>内容
 * </table>
 */
#include "global.h"
#define LOG_TAG TAG_MAIN

#include "cmsis_os2.h"

#include "easylog/elog.h"
#include "aadl/flash.h"
#include "flash_main.h"
#include "task_gnss.h"

#include "service/include/task_service.h"
#include "mmgr/include/task_mmgr.h"
#include "shell/task_shell.h"
#include "misc/task_misc.h"
#include "misc/hwmisc.h"
#include "comm/co_heartbeat.h"
#include "bsp_wdt.h"
#include "lowpower/include/task_lowpower.h"

extern int32_t qltask_gnss_start(void);
extern int32_t qltask_sensor_start(void);

#include "modem/qlmodem/task_modem.h"


#include "hal_adapter.h"
#include "../testcase/tc_main.h"

void bussiness_entry(void *argument)
{
    log_i("bussiness start!");
	bsp_wdt_feed();
	
    /* 1. 开机读取硬件版本 */
    misc_device_init(); 
	
    /* 2. shell 功能初始化入口 */
    userShellInit();
	bsp_wdt_feed();
	
    /* 3. modem线程入口 */
    qltask_mmgr_start();
    bsp_wdt_feed();
	
    /* 4. gsensor线程入口 */
    qltask_sensor_start();
    bsp_wdt_feed();
	
    /* 5. gnss线程入口 */
    qltask_gnss_start();
	bsp_wdt_feed();
	
    /* 6. 仪表通讯线程入口 */
    qltask_comm_start();
    bsp_wdt_feed();

    /* 7. 服务器功能线程入口 */
    qltask_service_start();
    bsp_wdt_feed();

    /* 8.低功耗线程入口 */
    qltask_lowpower_start();
	bsp_wdt_feed();

    while(1)
    {
#ifndef NDEBUG        
        testcase();
#endif        
        bsp_wdt_feed();
        osDelay(1000);
    }
}

#include "FreeRTOS.h"
#include "task.h"

/* 函数描述: 业务功能初始化，包含任务初始化等 */
int32_t sailvan_bussiness_init(void)
{ 
    if (xTaskCreate(bussiness_entry, "bussiness", TASKSTACK_BUSSINESS, NULL, TASKPRI_BUSSINESS, NULL) != pdPASS)
    {
        log_e("bussiness task create failed\r\n");
        Error_Handler();
    }

    return 0;
}



